<!DOCTYPE html>
<!--
     SPDX-License-Identifier: CC-BY-SA-4.0
     SPDX-FileCopyrightText: 2020 seL4 Project a Series of LF Projects, LLC.
-->
<!-- Page last generated 2025-02-20 03:16:15 +0000 -->
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Using Docker for seL4, Camkes, and L4v dependency management | seL4 docs</title>

    <!-- Our stylesheet and theme stylesheet.  Contains bootstrap. -->
    <link rel="stylesheet" href="/assets/css/style.css" type="text/css">
    <!-- Font awesome -->
    <link href="https://use.fontawesome.com/releases/v5.0.8/css/all.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
    <!-- Pygments syntax highlighting  -->
    <link rel="stylesheet" href="/assets/css/highlighting/trac.css" type="text/css">
    <link rel="icon" type="image/x-icon" href="/assets/favicon.ico"><script defer data-domain="docs.sel4.systems"
	    src="https://analytics.sel4.systems/js/script.js"></script></head>

  <body class="container-fluid">

    



<header>
  <ul class="row menu">
    <li class="col-xs-12 col-md-2" >
            <a href="https://sel4.systems" class="skip-icon">
              <img class="img-responsive" src="/assets/logo-text-white.svg" alt="seL4 logo" />
            </a>
    </li>
    <li class="col-xs-12 col-md-10 menu">
      <nav aria-label="Banner links">
        <h2><a href="/Resources" />Resources</h2>
        <h2><a href="/processes" />Contributing</a></h2>
        <h2><a href="/projects" />Projects</h2>
        <h2><a href="/Tutorials" />Tutorials</h2>
        <iframe title="DuckDuckGo search bar" src="https://duckduckgo.com/search.html?site=docs.sel4.systems&prefill=Search%20sel4.systems" style="overflow:hidden;margin-bottom:10px; padding:0;height:40px;float:right;border-width: 0px"></iframe>
      </nav>
    </li>
  </ul>
  <div class="clear"></div>
  
<div class="breadcrumbs bootstrap hidden-sm-down">
  <nav class="sel-breadcrumb" aria-label="Breadcrumb" >
    <ol class=" list-unstyled" vocab="http://schema.org/" typeof="BreadcrumbList">
      
      
        

        

        <li class="breadcrumb-item" property="itemListElement" typeof="ListItem">
            <a property="item" typeof="WebPage" href="/">
              <span property="name"><b>seL4 Docs</b></span>
            </a>
            <meta property="position" content="1" />
        </li>
      
        

        

        <li class="breadcrumb-item" property="itemListElement" typeof="ListItem">
            <a property="item" typeof="WebPage" href="/projects/">
              <span property="name"><b>Projects</b></span>
            </a>
            <meta property="position" content="2" />
        </li>
      
        

        
          <li class="breadcrumb-item" property="itemListElement" typeof="ListItem">
            <span property="name">Using Docker for seL4, Camkes, and L4v dependency management</span>
            <meta property="position" content="3" /></li>
          
    </ol>
  </nav>
  <nav class="sel-version" aria-label="Current Versions">
    <ol class="list-unstyled">
      <li class="list-unstyled text-right" style="margin-left:auto; padding:0rem 0rem;">
        Current versions:</li>
      <li class="list-unstyled text-right">
      <a href="/releases/sel4/13.0.0"><b>seL4-13.0.0</b></a></li>
      <li class="list-unstyled text-right">
      <a href="/releases/microkit/1.4.1"><b>microkit-1.4.1</b></a></li>
      <li class="list-unstyled text-right">
      <a href="/releases/camkes/camkes-3.11.0"><b>camkes-3.11.0</b></a></li>
      <li class="list-unstyled text-right">
      <a href="/releases/capdl/0.3.0"><b>capDL-0.3.0</b></a></li>
      </ol>
  </nav>
  <div class='clear'></div>
</div>


</header>

    <main>
      <div class="row">
  <div class="hidden-xs col-sm-4 col-md-3 col-lg-2">
    


<div class="sidebar">















    <ul class="nav nav-sidebar">
  
    
    

    
        <li class="">
            <a class="" href="/projects/sel4/">seL4</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/l4v/">L4.verified</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/camkes/">CAmkES</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/capdl/">CapDL</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/elfloader/">Elfloader</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/buildsystem/">seL4 Buildsystem</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/user_libs/">user_libs</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/sel4runtime/">The seL4 run-time</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/sel4webserver/">seL4webserver</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/sel4-tutorials/">seL4 tutorials</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/sel4bench/">sel4bench</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/sel4test/">seL4Test</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/virtualization/">Virtualization</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/camkes-vm/">camkes-vm</a>
        </li>
  
    
    

    
        <li class="active">
            <a class="" href="/projects/dockerfiles/">Dockerfiles</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/docsite/">seL4 Documentation website</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/sel4_tools/">seL4_tools</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/microkit/">Microkit</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/hardware_hacks/">Hardware Hacks</a>
        </li>
  
    
    

    
        <li class="">
            <a class="" href="/projects/rust/">Rust</a>
        </li>
  
    </ul>


</div>

  </div>
  <div class="content col-sm-8 col-md-6 col-lg-7 main">
    <h1 id="using-docker-for-sel4-camkes-and-l4v-dependency-management">Using Docker for seL4, Camkes, and L4v dependency management</h1>

<p>This page provides instructions on how to quickly set up your machine for building the seL4 kernel and related projects.</p>

<h2 id="requirements">Requirements:</h2>

<p>These instructions assume you are using Debian (or a derivative, such as Ubuntu), and are using Bash for your shell. However, it should be informative enough for users of other distros/shells to adapt.</p>

<p>To begin, you will need at least these two programs:</p>

<ul>
  <li>make (<code class="language-plaintext highlighter-rouge">sudo apt install make</code>)</li>
  <li>docker (See <a href="https://get.docker.com">here</a> or <a href="https://docs.docker.com/engine/installation">here</a> for installation instructions)</li>
</ul>

<p>For convenience, add your account to the Docker group:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>usermod <span class="nt">-aG</span> docker <span class="si">$(</span><span class="nb">whoami</span><span class="si">)</span>
</code></pre></div></div>

<p>Note that after doing so you may have to logout of your account and log back in for the change to have affect.</p>

<h2 id="getting-a-build-environment">Getting a build environment</h2>

<p>To get a running build environment for seL4 and Camkes, run:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git clone https://github.com/seL4/seL4-CAmkES-L4v-dockerfiles.git
<span class="nb">cd </span>seL4-CAmkES-L4v-dockerfiles
make user
</code></pre></div></div>

<p>This will give you a terminal inside a container that has all the relevant tools to build, simulate, and test seL4 &amp; Camkes programs.</p>

<p>The first time you run this, docker will fetch the relevant images, which may take a while.</p>

<p>To map a particular directory into the container:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>make user <span class="nv">HOST_DIR</span><span class="o">=</span>/scratch/seL4_stuff  <span class="c"># as an example</span>
<span class="c"># Now /host in the container maps to /scratch/seL4_stuff</span>
</code></pre></div></div>

<p>To make this easier to type, you can setup a bash alias such as this:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">echo</span> <span class="s1">$'alias container=</span><span class="se">\'</span><span class="s1">make -C /&lt;path&gt;/&lt;to&gt;/seL4-CAmkES-L4v-dockerfiles user HOST_DIR=$(pwd)</span><span class="se">\'</span><span class="s1">'</span> <span class="o">&gt;&gt;</span> ~/.bashrc
<span class="c"># now open a new terminal, or run `source ~/.bashrc`</span>
</code></pre></div></div>

<p>Replace <code class="language-plaintext highlighter-rouge">/&lt;path&gt;/&lt;to&gt;/</code> to match where you cloned the git repo of the docker files. This then allows you to run:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>container
</code></pre></div></div>

<p>to start the container in the current directory you are in.</p>

<h2 id="an-example-workflow">An example workflow:</h2>
<p>A good workflow is to run two terminals:</p>

<ul>
  <li>terminal A is just a normal terminal, and is used for git operations, editing (e.g., vim, emacs), and other normal operations.</li>
  <li>terminal B is running in a container, and is only used for compilation.</li>
</ul>

<p>This gives you the flexibility to use all the normal tools you are used to, while having the seL4 dependencies separated from your machine.</p>

<h3 id="compiling-sel4-test">Compiling seL4 test</h3>

<p>Start two terminals (terminal A and terminal B).</p>

<p>In terminal A, run these commands:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>jblogs@host:~<span class="nv">$ </span><span class="nb">mkdir</span> ~/seL4test
jblogs@host:~<span class="nv">$ </span><span class="nb">cd</span> ~/seL4test
jblogs@host:~/seL4test<span class="nv">$ </span>repo init <span class="nt">-u</span> https://github.com/seL4/seL4test-manifest.git
jblogs@host:~/seL4test<span class="nv">$ </span>repo <span class="nb">sync</span>
</code></pre></div></div>

<p>In terminal B, run these commands:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>jblogs@host:~<span class="nv">$ </span><span class="nb">cd</span> ~/seL4test
jblogs@host:~/seL4test<span class="nv">$ </span>container  <span class="c"># using the bash alias defined above</span>
jblogs@in-container:/host<span class="nv">$ </span><span class="nb">mkdir </span>build-x86
jblogs@in-container:/host<span class="nv">$ </span><span class="nb">cd </span>build-x86
jblogs@in-container:/host/build-x86<span class="nv">$ </span>../init-build.sh <span class="nt">-DPLATFORM</span><span class="o">=</span>x86_64 <span class="nt">-DSIMULATION</span><span class="o">=</span>TRUE 
jblogs@in-container:/host/build-x86<span class="nv">$ </span>ninja
</code></pre></div></div>

<p>If you need to make any code modifications or commit things to git, use terminal A. If you need to recompile or simulate an image, use terminal B.
Note, if QEMU fails when trying to simulate the image, try configuring your Docker host to give the container more memory.</p>

<h2 id="adding-dependencies">Adding dependencies</h2>
<p>To add more software inside the container, modify the <code class="language-plaintext highlighter-rouge">extras.dockerfile</code>. It contains an <code class="language-plaintext highlighter-rouge">apt-get</code> command which can be added to. After the first modification, docker will rebuild the extras image, and cache it after that.</p>

<h2 id="available-images">Available images</h2>

<p>All the prebuilt docker images are available on <a href="https://hub.docker.com/u/trustworthysystems">DockerHub here</a>
These images are used by the Trustworthy Systems Continuous Integration (CI) software, and so represent a standard software setup we use.</p>

<p>The CI software always uses the <code class="language-plaintext highlighter-rouge">latest</code> docker image, but images are also tagged with the date they were built.</p>

<h2 id="more-information">More information</h2>

<p>You can find the dockerfiles and supporting Makefile <a href="https://github.com/seL4/seL4-CAmkES-L4v-dockerfiles">here</a></p>

<p>Pull-requests and issues are <a href="https://docs.sel4.systems/Contributing">welcome</a>.</p>


  </div>







  
  
<div class="sidebar-toc hidden-xs hidden-sm col-md-3 col-lg-3">
  
    <ul class="section-nav">
    	<h2> Dockerfiles </h2> 
        <li>
          
          <a style=" font-weight: bold; " class="" href="/projects/dockerfiles/">
            Documentation homepage
          </a>
        </li>

















    
        <h3>Repositories</h3>
    
        <li>
          <a class="" href="https://github.com/sel4proj/seL4-CAmkES-L4v-dockerfiles">
            seL4-CAmkES-L4v-dockerfiles
          </a>
        </li>









  







    </ul>

</div>


</div>

    </main>
    


<footer class="site-footer">

  <h2 class="footer-heading">seL4 docs</h2>

  <div class="footer-col-wrapper">

    <div class="col-md-2">
      



<ul class="social-media-list">
  <li><a href="https://github.com/sel4"><i class="fab fa-github"></i> <span class="username">sel4</span></a></li><li><a href="https://github.com/sel4proj"><i class="fab fa-github"></i> <span class="username">sel4proj</span></a></li>
</ul>

    </div>

    <div class="col-md-8">
      <ul class="list-unstyled">
        <li>
          This site is for displaying seL4 related documentation.  Pull requests are welcome.
        </li>
        
          <li>
            Site last updated: Fri Feb 7 10:17:38 2025 +1100 ee78c8857c
          </li>
          <li>
                Page last updated: Thu Jan 4 17:23:26 2024 +1300 21a38d84cc
          </li>
        
      </ul>
    </div>
    <div class="col-md-2">
<a href="https://github.com/seL4/docs/blob/master/projects/dockerfiles/index.md">View page on GitHub</a>
      <br />
      <a href="https://github.com/seL4/docs/edit/master/projects/dockerfiles/index.md">Edit page on GitHub</a>
      <br />
      <a href="/sitemap">Sitemap</a>
    </div>

  </div>

</footer>

  </body>
</html>
